@extends("layouts.main")
@section("title","角色管理")
@section("page_title","角色管理")
@section("page_small_title","角色列表")

{{--生成面包屑--}}
@section("breadcrumbs")
    {!! Breadcrumbs::render('operation',[["name"=>"角色管理","url"=>"role.index"],["name"=>"角色列表"]]) !!}
@endsection

@section("content")
    <div class="box  box-success">
        <div class="box-header">
            <h3 class="box-title">
                <a href="{{url("/admin/role/create")}}" class="btn btn-sm btn-success"><i class="fa fa-fw fa-plus-circle"></i>添加</a>
            </h3>

            <div class="box-tools">
                <div class="input-group input-group-sm" style="width: 150px;">
                    <input type="text" name="table_search" class="form-control pull-right" placeholder="Search">
                    <div class="input-group-btn">
                        <button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
                    </div>
                </div>
            </div>
        </div>
        <div class="box-body table-responsive no-padding">
            <table class="table table-hover tree">
                <tr>
                    <th>名称</th>
                    <th>显示名称</th>
                    <th>描述</th>
                    <th>添加时间</th>
                    <th>更新时间</th>
                    <th>操作</th>
                </tr>
                @foreach($rows as $item)
                <tr>
                    <td>{{$item->name}}</td>
                    <td>{{$item->display_name}}</td>
                    <td>{{$item->description}}</td>
                    <td>{{$item->created_at}}</td>
                    <td>{{$item->updated_at}}</td>
                    <td>
                        <a href="{{url("admin/role/".$item->id."/edit")}}"><i class="fa fa-edit"></i> </a>
                        <a href="javascript:;" data-id="{{$item->id}}" class="_delete"><i class="fa fa-trash-o text-red"></i></a>
                    </td>
                </tr>
                 @endforeach
            </table>
        </div>
        <div class="box-footer clearfix">
            {{$rows->links()}}
        </div>
    </div>
@endsection


@section("script")
    <script type="text/javascript">
         $("._delete").click(function(){
              //获取data属性的值
              var id = $(this).data("id");
              if(confirm("确认删除吗？")){
                    $.post("/admin/role/"+id,{'_method':'delete','_token':'{{csrf_token()}}'},function () {
                         window.location.href='{{route('role.index')}}'
                    });
              }
         });
    </script>
@endsection